Jump to content
Electronics-Lab.com Community

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage


Recommended Posts

1. Compile the fw_printenv tool

Execute under the uboot source path, and then generate the executable file of the fw _ printenv under tools/env.

. /opt/fsl-imx-x11/4.1.15-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabimake env

2. Configure fw_env.config file

Modify the fw_env.config file under tools/env in the uboot source directory according to the mtd partition, the location and size of the UBOOT environment variables, etc. See the instructions in the fw_env.config file and the /tools/env/README file for specific modifications.

Among them, Device offset, Env size, and Flash sector size should correspond respectively to the three macro definitions CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, and CONFIG_ENV_SECT_SIZE in the include/configs/xxxx.h file in the U-Boot source code directory.

vi include/configs/mx6ul_14x14_evk.h

Take the test 256nand as an example:

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

CONFIG_ENV_OFFSET = 0x600000

ONFIG_ENV_SECT_SIZE = 0x20000

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Open the tools/env/fw_env.config and modify as shown in the following figures:

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Take the test 1gnand as an example:

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

CONFIG_ENV_OFFSET = 0x1000000

ONFIG_ENV_SECT_SIZE = 0x20000

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

nand model number MT29F8G08ABACA

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Refer to the manual to change the ENV_SECT_SIZE value to 256K.

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Open the tools/env/fw_env.config and modify as shown in the following figures:

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

nand model number MT29F8G08ABABA

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Refer to the manual to change the ENV_SECT_SIZE value to 512K.

Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Open the tools/env/fw_env.config and modify as shown in the following figures:

f_2633250b5fdf84dc7f6d42fee7feadc6&t=png

3. Copy the file

Copy tools/env/fw_env.config to the /etc path of the development board;

Copy tools/env/fw_printenv to the root file system of the development board under the path /usr/bin.

And create a soft link to fw_setenv ln -s /usr/bin/fw_printenv /usr/bin/fw_setenv

4. Read and write environment variable test

Read environment:

f_324510f98fd8f49df1a8e7842d0204fb&t=png

Write environment variable:

f_82df6e99a376f9441a1f9a92167120b6&t=png

The uboot phase has been modified synchronously.

f_1a6043e838da9025471f7a0c978830ed&t=png

5. Problems and solutions

Problem: make env reports an error in the uboot source code

f_86375eee7796e23ceebab0bd49dd03b4&t=png

Solution: Comment out the CC in the top-level Makefile and use the environment variable in the CC.

f_e92bf1c141611f64a60a8d998fcd401d&t=png

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...